Host *
    IdentitiesOnly yes

{% if hostvars[groups['virthost'][0]].ansible_host is defined %}

Host virthost
    Hostname {{ hostvars[groups['virthost'][0]].ansible_host }}
    IdentityFile {{ hostvars[groups['virthost'][0]].ansible_private_key_file }}
    User {{ ssh_user }}
    StrictHostKeyChecking no
    UserKnownHostsFile=/dev/null

{% else %}

Host virthost
    Hostname {{ hostvars['localhost'].ansible_default_ipv4.address }}
    IdentityFile {{ local_working_dir }}/id_rsa_virt_power
    User {{ ssh_user }}
    StrictHostKeyChecking no
    UserKnownHostsFile=/dev/null

{% endif %}

Host undercloud
    Hostname {{ hostvars['undercloud'].ansible_host }}
    IdentityFile {{ hostvars['undercloud'].ansible_private_key_file }}
    User {{ undercloud_user }}
    StrictHostKeyChecking no
    UserKnownHostsFile=/dev/null

{% if groups["overcloud"] is defined %}
{% for host in groups["overcloud"] %}

Host {{ host }}
    Hostname {{ hostvars[host].ansible_host }}
    ProxyCommand {{ ssh_proxy_command  }} -W {{ hostvars[host].private_v4 }}:22
    IdentityFile {{ hostvars[host].ansible_private_key_file }}
    User {{ overcloud_user | default ('tripleo-admin') }}
    StrictHostKeyChecking no
    UserKnownHostsFile=/dev/null

{% endfor %}
{% endif %}
